package trunk.besteAukera;

import java.awt.Color;
import java.awt.Graphics;
import java.util.Vector;

public class Xor extends AteLogikoak {
	private Hanka s1, s2, i1;
	private Color kolorea;
	private Vector<Hanka> hankaBektorea = new Vector<Hanka>();
	private Vector<Hanka> sarreraBektorea = new Vector<Hanka>();

	public Xor(int x1, int y1, int hankaKop, int sarKop, int r1, int r2,
			int g1, int g2, String motaFis) {
		super(x1, y1, hankaKop, sarKop, r1, r2, g1, g2, motaFis);
		// TODO Auto-generated constructor stub

		if (motaFisikoa.compareTo("and") == 0) {
			System.out.println("tengo un katarrazoooo1!!!");
			s1 = new Hanka(x + 5, y + rad2 / 4, "positiboa", "s", 0, this, "h","ez");
			s2 = new Hanka(x + 5, y + rad2 - rad2 / 4, "positiboa", "s", 1,
					this, "h","ez");
			i1 = new Hanka(x + rad1 + 20, y + rad2 / 2, "positiboa", "i", 2,
					this, "h","ez");
		} else if (motaFisikoa.compareTo("nor") == 0) {
			s1 = new Hanka(x + 5, y + 12, "negatiboa", "s", 0, this, "h","ez");
			System.out.println("tengo un katarrazoooo!!!2");
			s2 = new Hanka(x + 5, y + 36, "negatiboa", "s", 1, this, "h","ez");

			i1 = new Hanka(x + rad1 + 20, y + 24, "positiboa", "i", 2, this, "h","ez");
		} else if (motaFisikoa.compareTo("nand") == 0) {
			System.out.println("tengo un katarrazoooo3!!!");
			s1 = new Hanka(x + 5, y + 12, "positiboa", "s", 0, this, "h","ez");

			s2 = new Hanka(x + 5, y + 36, "positiboa", "s", 1, this, "h","ez");

			i1 = new Hanka(x + 20 + 70, y + 24, "negatiboa", "i", 2, this, "h","ez");
		}

		else if (motaFisikoa.compareTo("or") == 0) {
			System.out.println("tengo un katarrazoooo4!!!");
			s1 = new Hanka(x + 5, y + 12, "negatiboa", "s", 0, this, "h","ez");
			s2 = new Hanka(x + 5, y + 36, "negatiboa", "s", 1, this, "h","ez");
			i1 = new Hanka(x + 20 + 70, y + 24, "negatiboa", "i", 2, this, "h","ez");
		}

		lotList[0] = s1;
		lotList[1] = s2;
		lotList[2] = i1;
	}

	@Override
	public void funtzioLogikoa(Integer... values) {

		// TODO Auto-generated method stub
		lotList[2].getIrteera().setBalioa(s1.getSarrera().getBalioa() ^ s2.getSarrera().getBalioa());
	}

	public boolean estaDentro(int x, int y) {
		if ((x > this.x) && (x < (this.x + rad1)) && (y > this.y)
				&& (y < (this.y + rad2))) {
			return true;
		}

		return false;

	}

	public Integer equ(Integer s1, Integer s2) {
		if (s1 == s2)
			return 1;
		else
			return 0;
	}

	@Override
	public Vector<Hanka> getHankak() {
		// TODO Auto-generated method stub
		hankaBektorea = new Vector<Hanka>();
		hankaBektorea.addElement(s1);
		hankaBektorea.addElement(s2);
		hankaBektorea.addElement(i1);
		return hankaBektorea;
	}

	 public void dibujate(Graphics g)
	    {
		 g.setColor(Color.black);
		 g.drawArc(x, y, rad1, rad2, grad1, grad2);
   g.drawArc(x, y, rad1-40, rad2, grad1, grad2);
   g.drawArc(x+12, y, rad1-40, rad2, grad1, grad2);


  
   s1.dibujate(g);
   s2.dibujate(g);
   i1.dibujate(g);
}

	public void setPosicion(int x1, int y1) {
		this.x = x1;
		this.y = y1;

	}

	public int getX() {
		return x;
	}

	public int getY() {
		return y;
	}

	@Override
	public Hanka getIrteeraHanka() {
		// TODO Auto-generated method stub
		return i1;
	}

	@Override
	public Vector<Hanka> getSarreraHankak() {
		// TODO Auto-generated method stub
		sarreraBektorea = new Vector<Hanka>();
		sarreraBektorea.addElement(s1);
		sarreraBektorea.addElement(s2);
		return sarreraBektorea;
	}

	public Integer getData1() {
		return data1;
	}

	public Integer getData2() {
		return data2;
	}

	public void setEmaitza(Integer em) {
		emaitza = em;

	}

}

